import br.com.nooclix.salon.ui.util.LoginControl;
import br.com.nooclix.salon.ui.util.MenuButton;

import flash.events.MouseEvent;
import flash.net.getClassByAlias;

import mx.controls.Alert;
import mx.controls.Button;

private var lastY:int = 0;
private var newY:int = 0;
private var lastButtonSize:int = 0;
private var homeOk:Boolean = false;
//Essa classe é responsável por gerar a imagem da página inicial
//Essa function cria o botão na tela
public function addToBar(b:Button):void{
	
	b.y = newY;
	lastY = b.y;
	
	if((b as MenuButton).text == "Página Inicial"){
		b.y = 6;
		lastY = 6;
		homeOk = true;
	}
	
	lastButtonSize = b.height;
	newY = lastButtonSize + b.y + 2;
	barMenu.addElement(b);

}

public function createMenu():void{
	//Aqui ele cria o botão para aparecer na tela
	//é informado qual o botão que quer criar na tela
	addToBar(buttonCustomer());
	addToBar(buttonEmployee());
	addToBar(buttonService());
	addToBar(buttonProduct());
	addToBar(buttonAttendance());
	addToBar(buttonReport());
	
}

public function buttonCustomer():Button{
	[Embed("../icons/menubutton/customers.png")]
		var iconCustomer:Class;
		
		var buttonCustomer:MenuButton = new MenuButton("Cliente");
		buttonCustomer.setStyle("icon",iconCustomer);
		buttonCustomer.addEventListener(MouseEvent.CLICK, function ():void{
									openCustomer();
								});
		
		return buttonCustomer;
}

public function buttonService():Button{
	[Embed("../icons/menubutton/scissors.png")]
	var iconService:Class;
	
	var buttonService:MenuButton = new MenuButton("Serviços");
	buttonService.setStyle("icon",iconService);
	buttonService.addEventListener(MouseEvent.CLICK, function ():void{
		openService();
	});
	
	return buttonService;
}
//Aqui eu posso alterar a imagem que irá aparecer na tela inicial do sistema
public function buttonEmployee():Button{
	[Embed("../icons/menubutton/employee.png")]
	var iconEmployee:Class;
	
	var buttonEmployee:MenuButton = new MenuButton("Funcionários");
	buttonEmployee.setStyle("icon",iconEmployee);
	buttonEmployee.addEventListener(MouseEvent.CLICK, function ():void{
		openEmployee();
	});
	
	return buttonEmployee;
}

public function buttonProduct():Button{
	[Embed("../icons/menubutton/product.png")]
	var iconProduct:Class;
	
	var buttonProduct:MenuButton = new MenuButton("Produtos");
	buttonProduct.setStyle("icon",iconProduct);
	buttonProduct.addEventListener(MouseEvent.CLICK, function ():void{
		openProduct();
	});
	
	return buttonProduct;
}

public function buttonAttendance():Button{
	[Embed("../icons/menubutton/attendance.png")]
	var iconAttendance:Class;
	
	var buttonAttendance:MenuButton = new MenuButton("Atendimentos / Reservas");
	buttonAttendance.setStyle("icon",iconAttendance);
	buttonAttendance.addEventListener(MouseEvent.CLICK, function ():void{
		openAttendance();
	});
	
	return buttonAttendance;
}

public function buttonReport():Button{
	[Embed("../icons/menubutton/report.png")]
	var iconReport:Class;
	
	var buttonReport:MenuButton = new MenuButton("Relatórios");
	buttonReport.setStyle("icon",iconReport);
	buttonReport.addEventListener(MouseEvent.CLICK, function ():void{
		openReport();
	});
	
	return buttonReport;
}

